package com.components;

import com.argsstack.Args;
import com.exceptions.PreIsNotSatisfiedException;
import com.post.BasicPost;
import com.pre.BasicPre;

/**
 * @author sad
 */
public class SendMailComponent extends BaseComponent {

    public SendMailComponent() {
        super("SendMail");
    }

    @Override
    public BasicPost post(Args args) {
        return BasicPost.TruePost;
    }

    @Override
    public BasicPre pre(Args args) {
        checkPrerequisites(args, "value");
        if (args.get("value").getAttribute("type") != String.class) {
            throw new PreIsNotSatisfiedException();
        }
        return BasicPre.TruePre;
    }

    @Override
    public void execute(Args args) {
        String value = (String) args.get("value").getValue();
        int iValue = Integer.parseInt(value);
        args.setValue("value", iValue);
    }
}
